/****** Object:  Stored Procedure [dbo].sporder_itemInsert Script Date: 11/24/2012 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[sporder_itemInsert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
	DROP PROCEDURE [dbo].[sporder_itemInsert]
GO

/******************************************************************************
**		Name: [dbo].sporder_itemInsert
**		Desc:
**
**		Return values:
**
**		Called by:
**
**		Parameters:
**		Input						Output
**		----------					----------
**
**		Auth: MinhSong
**		Date: 11/24/2012
*******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:					Description:
**		--------	--------				-----------------------------------
**
*******************************************************************************/

CREATE PROCEDURE [dbo].[sporder_itemInsert]
(
	@OrderID int,
	@ProductID int,
	@Quantity int,
	@Price real,
	@CreateBy nvarchar(50),
	@ItemID int output
)
WITH ENCRYPTION

AS

SET NOCOUNT ON

INSERT INTO [tbl_order_items]
(
	[OrderID],
	[ProductID],
	[Quantity],
	[Price],
	[CreateBy],
	[CreateDate]
)
VALUES
(
	@OrderID,
	@ProductID,
	@Quantity,
	@Price,
	@CreateBy,
	getdate()
)

SELECT @ItemID = SCOPE_IDENTITY()
--SELECT @Id = @@IDENTITY
GO

--GRANT EXECUTE ON [dbo].[sporder_itemInsert] TO [sa]
--GO
